<?php
namespace Foam\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\EventManager\EventManagerInterface;
use Zend\View\Model\ViewModel;
use Zend\View\Model\JsonModel;

class IndexController extends AbstractActionController
{
    protected $produitTable;
    
    public function setEventManager(EventManagerInterface $events)
    {
        parent::setEventManager($events);
 
        $controller = $this;
        $events->attach('dispatch', function ($e) use ($controller) {
            $controller->layout()->setTemplate('layout/foam');
        }, 100);
 
        return $this;
    }
    
    public function indexAction()
    {
        return new ViewModel();
    }
    
    public function xeditableAction()
    {        
        $data = array(
            array('value' => 0, 'text' => 'Non'),
            array('value' => 1, 'text' => 'Oui'),
        );

        $jsonModel = new JsonModel($data);
        
        return $jsonModel;
    }
}